package jdk8;

import java.util.*;
import java.util.function.Function;

/**
 * @author oldliu
 * @since 1.0
 */
public class FunctionTest {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("老虎");
        list.add("tiger");
        list.add("cat");
        list.add("小猫");
        list.add("pig");
        //存放list中每个值的字节长度
        List<Integer> l2=new ArrayList<>();
        Function<String,Integer> f=(x)->{
            return x.getBytes().length;
        };
        for(String s:list){
            Integer i = f.apply(s);
            System.out.println(i);
        }
        System.out.println(">>>>>>删除后>>>>>>>");
        list.removeIf(x->{
           return x.length()>3;//true继续
        });
        System.out.println(list);
        //>>>list.stream().flatMap()
    }
}
